home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK2.toast / Development Kits (Disc 2) / ScriptX / Draggable ScriptX Folders / utils / memory / moo.sx < prev   
Encoding:
Text File  |  1995-12-14  |  3.0 KB  |  103 lines  |  [TEXT/ttxt]

  1. <<<
  2. -- moo:  memory overhead overseer
  3. -- by Erik Neumann & Vidur Apparao, November 1994
  4. -- moo can be used to see whether memory is being used up between scenes
  5. /* 
  6. How to use this memory utility:
  7. 1) open this file within ScriptX to define the functions contained herein.
  8. 2) in the listener type moo()
  9. 3) do some stuff (make objects, run your title, etc.)
  10. 4) type moo() again to see overall changes in memory.
  11. 5) you can run moo() as many times as you want.
  12. 6) if you want to reset moo, type: mooReset()
  13.  
  14. The first time moo is run it will measure and remember the state of memory.
  15. After the first time, you will see a display like this:
  16.  
  17. "      free sys: 6102688       heap used: 658752       total heap: 946176"
  18. "delta free sys: 247280  delta heap used: -2368  delta total heap: 0"
  19. "cumul free sys: -1648  cumul used heap: -107296  cumul total heap: 0"
  20. "adj cumul free sys: -1648"
  21.  
  22. free sys = the amount of free system memory (ie. non-ScriptX heap, which
  23.             is where large data like bitmaps go)
  24. heap used = amount of ScriptX object heap now in use.
  25. total heap = total size of ScriptX object heap.  When this goes up, the 
  26.              ScriptX heap has run out of memory and had to be expanded.
  27. adj cumul free sys = cumulative change in free system heap excluding expansion
  28.              of the ScriptX heap.
  29.              
  30. To make moo forget the current state and start over, type: mooReset().
  31.  
  32. */
  33.  
  34. global savefreesys := 0
  35. global savefreeheap := 0
  36. global savetotalheap := 0
  37. global startfreesys := 0
  38. global startfreeheap := 0
  39. global starttotalheap := 0
  40.  
  41. function mooReset -> (
  42.  savefreesys := 0
  43.  savefreeheap := 0
  44.  savetotalheap := 0
  45.  startfreesys := 0
  46.  startfreeheap := 0
  47.  starttotalheap := 0
  48. )
  49.  
  50. function moo -> (
  51. local caption
  52. garbagecollect()
  53.  
  54. local newfreesys := totalfreesystemspace()
  55. local newfreeheap := totalfreeheapspace()
  56. local newtotalheap := totalheapspace()
  57. caption := ("      free sys: " + (newfreesys as String) +
  58.         "       heap used: " + ((newtotalheap - newfreeheap) as String) +
  59.         "       total heap: " + (newtotalheap as String))
  60. print caption
  61.  
  62. if (savefreesys = 0) do
  63. (
  64.     savefreesys := newfreesys
  65.     savefreeheap := newfreeheap
  66.     savetotalheap := newtotalheap
  67. )
  68.  
  69. caption := ("delta free sys: " + 
  70.             ((newfreesys - savefreesys) as String) + 
  71.            "  delta heap used: " + 
  72.            (((newtotalheap - newfreeheap) - (savetotalheap - savefreeheap)) as String) + 
  73.            "  delta total heap: " + 
  74.             ((newtotalheap - savetotalheap) as String))
  75. print caption
  76. savefreesys := newfreesys
  77. savefreeheap := newfreeheap
  78. savetotalheap := newtotalheap
  79.  
  80. if (starttotalheap = 0) do
  81. (
  82.     startfreesys := newfreesys
  83.     startfreeheap := newfreeheap
  84.     starttotalheap := newtotalheap
  85. )
  86.  
  87. caption := ("cumul free sys: " +
  88.         ((newfreesys - startfreesys) as String) +
  89.         "  cumul used heap: " +
  90.         (((newtotalheap - newfreeheap) - (starttotalheap - startfreeheap)) as String) +
  91.         "  cumul total heap: " +
  92.         ((newtotalheap - starttotalheap) as String))
  93. print caption
  94.  
  95. caption := ("adj cumul free sys: " +
  96.         (((newfreesys - startfreesys) + (newtotalheap - starttotalheap)) as String))
  97. print caption
  98.  
  99. --memoryusage(20)
  100. OK
  101. )
  102. >>>
  103.